const { Route, IndexRoute } = dva.router;
const RouteUtils = require('./utils/RouteUtils.jsx');
const App = require('./components/app/App.jsx');
const Center = require('./components/app/Center.jsx');
import PermissionSelectResources from './components/sys/permission/SelectResources.jsx'
import PermissionQueryResources from './components/sys/permission/QueryResources.jsx'
import RoleSelectPermission from './components/sys/role/SelectPermission.jsx'
import RoleQueryPermission from './components/sys/role/QueryPermission.jsx'

const formName = '数据表单';

const routes = (
    <Route path='/' component={require('./components/Index.jsx')}>
        <Route path='login' component={require('./components/Login.jsx')} />
        <Route component={App}>
            <IndexRoute component={Center}/>
            <Route path='index' component={Center} />
            <Route path='sys'>
                <Route path="module">
                    <IndexRoute component={require('./components/sys/module/View.jsx')}/>
                    <Route path="form" name={formName} component={require('./components/sys/module/Form.jsx')} />
                </Route>
                <Route path="resources">
                    <IndexRoute component={require('./components/sys/resources/View.jsx')}/>
                    <Route path="form" name={formName} component={require('./components/sys/resources/Form.jsx')} />
                </Route>
                <Route path="permission">
                    <IndexRoute component={require('./components/sys/permission/View.jsx')}/>
                    <Route path="form" name={formName} component={require('./components/sys/permission/Form.jsx')} />
                    <Route path="selectResources" name='选择资源' component={PermissionSelectResources} />
                    <Route path="queryResources" name='查看资源' component={PermissionQueryResources} />
                </Route>
                <Route path="role">
                    <IndexRoute component={require('./components/sys/role/View.jsx')}/>
                    <Route path="form" name={formName} component={require('./components/sys/role/Form.jsx')} />
                    <Route path="selectPermission" name='添加权限' component={RoleSelectPermission} />
                    <Route path="queryPermission" name='查看权限' component={RoleQueryPermission} />
                </Route>
                <Route path="user">
                    <IndexRoute component={require('./components/sys/user/View.jsx')}/>
                    <Route path="form" name={formName} component={require('./components/sys/user/Form.jsx')} />
                    <Route path="password" name='修改密码' component={require('./components/sys/user/UpdatePassword.jsx')} />
                </Route>
            </Route>
            <Route path='overtime'>
                <Route path="record">
                    <IndexRoute component={require('./components/overtime/record/View.jsx')}/>
                    <Route path="form" name={formName} component={require('./components/overtime/record/Form.jsx')} />
                    <Route path="batchForm" name='批量添加' component={require('./components/overtime/record/BatchForm.jsx')} />
                </Route>
                <Route path="statistics">
                    <IndexRoute component={require('./components/overtime/statistics/View.jsx')}/>
                </Route>
            </Route>
            <Route path='personal'>
                <Route path="updatePasswordPage" component={require('./components/personal/UpdatePassword.jsx')} />
                <Route path="userInfo" component={require('./components/personal/UpdateUserInfo.jsx')} />
            </Route>
            <Route path="invalid" component={require('./components/error/Invalid.jsx')} />
            <Route path="403" component={require('./components/error/403.jsx')} />
            <Route path="*" component={require('./components/error/404.jsx')} />
        </Route>
    </Route>
);

const breadCrumbRouteMap = new Map();
RouteUtils.getRoutePath(routes, '', breadCrumbRouteMap);

module.exports = {
    routes: routes,
    breadCrumbMap: breadCrumbRouteMap
};